package com.gwz.bus.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gwz.bus.service.InportService;
import com.gwz.bus.vo.InportVo;
import com.gwz.sys.utils.DataGridView;
import com.gwz.sys.utils.ResultObj;
import com.gwz.sys.utils.WebUtils;

@RestController
@RequestMapping("inport")
public class InportController {

	@Autowired
	private InportService inportService;
	
	/**
	 * 加载进货列表
	 */
	@RequestMapping("loadAllInports")
	public DataGridView loadAllInports(InportVo inportVo) {
		return this.inportService.queryAllInports(inportVo);
	}
	
	/**
	 * 添加
	 */
	@RequestMapping("addInport")
	public ResultObj addInport(InportVo inportVo){
		try {
			inportVo.setInporttime(new Date());
			inportVo.setOperateperson(WebUtils.getCurrentUser().getName());
			this.inportService.addInport(inportVo);
			return new ResultObj(200, "添加成功");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new ResultObj(-1, "添加失败");
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("deleteInport")
	public ResultObj deleteInport(InportVo inportVo){
		try {
			//做删除
			this.inportService.deleteInport(inportVo.getId());
			return new ResultObj(200, "删除成功");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new ResultObj(-1, "修改失败");
	}
}
